function [ tradeInfoList,trgtList ] = findTargetTrade( infoList,tradeTime,delay,trgt )
  % findTargetTrade: 通过给定得持有时间和交易延迟寻找达到给定利润率的交易点
  %
  % tradeInfoList {
  %   buyStartDate:买入开始日
  %   buyEndDate:买入结束日
  %   buyPrice:最高买入价
  %   sellStartDate:卖出开始日
  %   sellEndDate:卖出结束日
  %   sellPrice:最低卖出价
  %   minProfit:最小利润
  %   minProfitRate:最小利润率
  % }
  %
  % 交易公式:令开始日为X
  % 买入日 = [x+1,x+delay]
  % 持有期间为 [x+delay+1,x+delay+tradeTime]
  % 卖出日 = [x+delay+tradeTime+1,x+delay+tradeTime+delay]
  %
  % Extended description

  testDays = size(infoList,1)-tradeTime-2*delay;
  sellBegin = delay+tradeTime;

  buyPrice = zeros(delay,testDays+1);
  sellPrice = zeros(delay,testDays+1);

  for i=1:delay
    buyPrice(i,:) = [infoList(i:i+testDays).high];
    sellPrice(i,:) = [infoList(sellBegin+i:sellBegin+i+testDays).low];
  end

  buyStartDate = {infoList(1:1+testDays).date};
  buyEndDate = {infoList(delay:delay+testDays).date};

  sellStartDate = {infoList(sellBegin+1:sellBegin+1+testDays).date};
  sellEndDate = {infoList(sellBegin+delay:sellBegin+delay+testDays).date};

  maxBuyPrice = max(buyPrice);
  minSellPrice = min(sellPrice);

  profitList = minSellPrice - maxBuyPrice;
  profitRateList = profitList./maxBuyPrice;

  trgtList = profitRateList > trgt;

  T = table(buyStartDate',buyEndDate',maxBuyPrice',...
  sellStartDate',sellEndDate',minSellPrice',...
  profitList',profitRateList',...
  'VariableNames',{'buyStartDate','buyEndDate','buyPrice','sellStartDate','sellEndDate','sellPrice','minProfit','minProfitRate'});
  tradeInfoList = table2struct(T);
  tradeInfoList = tradeInfoList(trgtList);

end  % findTargetTrade
